//
//  RootViewController.m
//  Qya
//
//  Created by maxwellpang on 12-9-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "RootViewController.h"
#import "keywordViewController.h"
#import "EmailViewController.h"
#import "FieldViewController.h"


@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
//    [guideImage setImage:[UIImage imageNamed:@"guide.png"]];
    [earthImage setFrame:CGRectMake(0,480, 320, 480)];
    loginVC = [[LoginViewController alloc]init];
    [self.view addSubview:loginVC.view];
    
    self.navigationItem.hidesBackButton = YES;
    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"root芽信" style:UIBarButtonItemStylePlain target:self action:@selector(emailAction:)];  
    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"root边栏" style:UIBarButtonItemStylePlain target:self action:@selector(menuAction:)];
    self.navigationItem.rightBarButtonItem = rightButton;
    self.navigationItem.leftBarButtonItem = leftButton;
    
    [self.navigationController setToolbarHidden:YES animated:NO];
    [self.navigationController setNavigationBarHidden:YES animated:NO];

    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void)selectLeftAction:(id)sender  
{  
    UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:@"你点击了导航栏左按钮" delegate:self  cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];  
    [alter show];  
}  

-(void)selectRightAction:(id)sender  
{  
    UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:@"你点击了导航栏右按钮" delegate:self  cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];  
    [alter show];  
}  

-(IBAction)sowSeed:(id)sender
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:@"moveDown" context:context];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationFinished)];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.8];
    
    //    [self.view setAlpha:0.0f];
    CGPoint center = guideImage.center;
    center.y = center.y - 421;
    guideImage.center = center;

    CGPoint earthCenter = earthImage.center;
    earthCenter.y = earthCenter.y - 480;
    earthImage.center = earthCenter;
    
    CGPoint sowCenter = btSow.center;
    sowCenter.y = sowCenter.y - 480;
    btSow.center = sowCenter;
    
    [UIView commitAnimations];
    
 
}

- (void)animationFinished
{
    keywordViewController *secondView = [[keywordViewController alloc] init];  
    [self.navigationController pushViewController:secondView animated:NO];  
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    //    [UIView endAnimations
    secondView.title = @"关键词"; 
}

//展示侧边菜单
-(void)menuAction:(id)sender  
{  
    
}

-(void)emailAction:(id)sender  
{  
    EmailViewController *secondView = [[EmailViewController alloc] init];  
    [self.navigationController pushViewController:secondView animated:YES];  
    secondView.title = @"我的芽信"; 
}

@end
